<?php

class InstallController extends Zend_Controller_Action {

    public function init() {
        $this->_helper->layout->setLayout("install");
    }

    public function indexAction() {
        $form = new Application_Form_Createuser();
        $this->view->form = $form;

        if ($this->getRequest()->isPost()) {
            if ($form->isValid($this->getRequest()->getPost())) {
                $values = $form->getValues();
                $data = array(
                    'email' => $values['email'],
                    'password' => md5($values['password']),
                    'user_type' => $values['type'],
                    'details' => json_encode(array('name' => $values['name'], 'details' => $values['details'], 'profileUrl' => $values['profileUrl'])));
                $userDb = new Application_Model_Users();
                $userDb->createNew($data);
                $this->view->isSuccess = true;
            }
        }
    }

}

